home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 2
/
Gold Medal Software Volume 2 (Gold Medal) (1994).iso
/
prog
/
asm_n_z.arj
/
PARSE.DOC
< prev
next >
Wrap
Text File
|
1986-01-19
|
3KB
|
76 lines
PARSE.DOC
INTRODUCTION
The ability to use the command line allows a program to be used in batch
files without the use ofmenus and the required human intervention.
PARSE.ASM will give an assembly language program the ability to use the
command line.
BACKGROUND
When DOS loads a program to be executed, it builds a Program Segment Prefix
(PSP). DOS stores everything that was entered after the name of the program
up to the Carriage Return in an area of the PSP starting at location 81
hex(h). While the maximum length of the command line is 127 (79h), the
actual length of the entered string is stored as a binary number at location
80h. Redirection parameters (e.g. <INPUT or >OUTPUT) are not included.
This area is also the default Data Transfer Area (DTA). This means that the
command line information will be overwritten and lost if I/O is performed
using File Control Blocks (FCB) and the DTA has not been moved. While the
area should be safe if the extended file management functions (3ch to 46h)
are used, the author has discovered that functions 4eh and 4fh (Find First
and Find Next) do use the area. PARSE has several other advantages also.
WHAT PARSE DOES
PARSE performs the following tasks in the following order:
- Determines if there are any command line arguments (if none, MENU is
called.)
- Moves the entire command line onto the stack.
- Converts all blanks (ASCII 32) and below into null byte (all zeros
bits).
- Places the offset to the 1st byte of each command line argument
onto the stack.
- Places the total number of arguments onto the stack.
- Calls CMDLN
On entry to CMDLN and assuming a standard entry logic of "push bp" and "mov
bp,sp", the stack is arranged thusly:
offset from SP => 0/1 value of BP
2/3 return address
4/5 number of arguments
6/7 address of 1st argument
8/9 address of 2nd argument etc.
Thus, [bp-4] can be treated as argc in the "c" language, and [bp-6] can be
treated as the first pointer in an array of pointers, similiar to argv in
the "c" language. The length of argv is argc words. The actual command
line arguments start right after the last element of argv. The BP register
now allows all the command line information to be available to the program.
OTHER FEATURES
PARSE is also a template for a program in the .COM file format. The most
important feature the GROUP pseudo-op which will collect the segments under
one name so they all reside within a 64K physsical segment. Using this
pseudo-op removes the disadvantage of combining the data and code into one
segment.
A comment field is set up between the two astericks. Equate and macro files
will be included but neither will appear in the .LST file.
COMMENTS
This code is released into the public domain without any restrictions as to
its use.
The author has taken due care in writing this code, and the code is supplied
as is. The author makes no expressed or implied warranty of any kind with
regard to this code. In no event shall the author be liable for incidental
or conseqential damages in connection with or arising out of the use of this
code.
The author encourages comments. Please leave comments, or suggestions in a
message on Andy Smith's RBBS (301)-956-3396.
19 Jan 85 Raymond Moon